<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        
    </style>
</head>
<body>
    <div id="app">
        <input type="text" v-model="firstName">
        <input type="text" v-model="lastName">
        <input type="text" v-model="name">
        <br>
        <input type="text" v-model="firstName2">
        <input type="text" v-model="lastName2">
        <input type="text" v-model="name2">
    </div>
</body>
<script src="../libs/vue.min.js"></script>
<script>
    new Vue({
        el:"#app",
        data() {
            return {
                firstName:"",
                lastName:"",
                name:"",
                firstName2:"",
                lastName2:"",
            }
        },
        watch: {
            firstName(newVal, oldVal){
                // console.log(`老：${oldVal}，新：${newVal}`)
                this.name = newVal + this.lastName;
            },
            lastName(newVal, oldVal){
                // console.log(`老：${oldVal}，新：${newVal}`)
                this.name = this.firstName + newVal;
            }
        },
        computed:{
            name2(){
                return this.firstName2 + this.lastName2;
            }
        }
    })
</script>
</html>